//
//  ScrollViewLabelCell.m
//  ProjectforHDX
//
//  Created by Jaesun on 16/12/6.
//  Copyright © 2016年 H.DX. All rights reserved.
//

#import "ScrollViewLabelCell.h"

#define SCREEN_WIDTH CGRectGetWidth([[UIScreen mainScreen] bounds])

@implementation ScrollViewLabelCell

- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(20, 0, SCREEN_WIDTH - 80, 44)];
        self.scrollView = [[BDTouchScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH - 80, 44)];
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.font = [UIFont systemFontOfSize:17];
        [view addSubview:self.scrollView];
        [self.scrollView addSubview:self.titleLabel];

        [self.contentView addSubview:view];
        
    }
    
    return self;
}

- (void)setTitle:(NSString *)title {
    _title = title;
    
    CGRect rect = [title boundingRectWithSize:CGSizeMake(MAXFLOAT, 44) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17]} context:nil];
    self.titleLabel.text = title;
    self.titleLabel.frame = CGRectMake(0, 0, rect.size.width, 44);
    
    self.scrollView.contentSize = self.titleLabel.frame.size;
}

- (void)tapGestureAction:(UIGestureRecognizer *)sender {
    self.scrollTouchEvent();
}


@end
